00001 #ifndef LCD_H
00002 #define LCD_H
00003
00004
00005
00006
00007
00008
00009
00010
00035
00036 #if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
00037 #error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
00038 #endif
00039
00040 #include <inttypes.h>
00041 #include <avr/pgmspace.h>
00042
00047 #define XTAL 4000000
00054 #define LCD_CONTROLLER_KS0073 0
00060 #define LCD_LINES 4
00061 #define LCD_DISP_LENGTH 20
00062 #define LCD_LINE_LENGTH 0x40
00065 #define LCD_START_LINE1 0x00
00066 #define LCD_START_LINE2 0x14
00067 #define LCD_START_LINE3 0x40
00068 #define LCD_START_LINE4 0x54
00072 //#define LCD_START_LINE1 0x00
00073 //#define LCD_START_LINE2 0x40
00074 //#define LCD_START_LINE3 0x14
00075 //#define LCD_START_LINE4 0x54
00076 #define LCD_WRAP_LINES 0
00079 #define LCD_IO_MODE 1
00080 #if LCD_IO_MODE
00081
00095 #define LCD_PORT PORTA
00096 #define LCD_DATA0_PORT LCD_PORT
00097 #define LCD_DATA1_PORT LCD_PORT
00098 #define LCD_DATA2_PORT LCD_PORT
00099 #define LCD_DATA3_PORT LCD_PORT
00100 #define LCD_DATA0_PIN 0
00101 #define LCD_DATA1_PIN 1
00102 #define LCD_DATA2_PIN 2
00103 #define LCD_DATA3_PIN 3
00104 #define LCD_RS_PORT LCD_PORT
00105 #define LCD_RS_PIN 4
00106 #define LCD_RW_PORT LCD_PORT
00107 #define LCD_RW_PIN 5
00108 #define LCD_E_PORT LCD_PORT
00109 #define LCD_E_PIN 6
00111 #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
00112 defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
00113 defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
00114
00115
00116
00117 #define LCD_IO_DATA 0xC000
00118 #define LCD_IO_FUNCTION 0x8000
00119 #define LCD_IO_READ 0x0100
00120 #else
00121 #error "external data memory interface not available for this device, use 4-bit IO port mode"
00122
00123 #endif
00124
00125
00132
00133 #define LCD_CLR 0
00134 #define LCD_HOME 1
00135 #define LCD_ENTRY_MODE 2
00136 #define LCD_ENTRY_INC 1
00137 #define LCD_ENTRY_SHIFT 0
00138 #define LCD_ON 3
00139 #define LCD_ON_DISPLAY 2
00140 #define LCD_ON_CURSOR 1
00141 #define LCD_ON_BLINK 0
00142 #define LCD_MOVE 4
00143 #define LCD_MOVE_DISP 3
00144 #define LCD_MOVE_RIGHT 2
00145 #define LCD_FUNCTION 5
00146 #define LCD_FUNCTION_8BIT 4
00147 #define LCD_FUNCTION_2LINES 3
00148 #define LCD_FUNCTION_10DOTS 2
00149 #define LCD_CGRAM 6
00150 #define LCD_DDRAM 7
00151 #define LCD_BUSY 7
00152
00153
00154 #define LCD_ENTRY_DEC 0x04
00155 #define LCD_ENTRY_DEC_SHIFT 0x05
00156 #define LCD_ENTRY_INC_ 0x06
00157 #define LCD_ENTRY_INC_SHIFT 0x07
00158
00159
00160 #define LCD_DISP_OFF 0x08
00161 #define LCD_DISP_ON 0x0C
00162 #define LCD_DISP_ON_BLINK 0x0D
00163 #define LCD_DISP_ON_CURSOR 0x0E
00164 #define LCD_DISP_ON_CURSOR_BLINK 0x0F
00165
00166
00167 #define LCD_MOVE_CURSOR_LEFT 0x10
00168 #define LCD_MOVE_CURSOR_RIGHT 0x14
00169 #define LCD_MOVE_DISP_LEFT 0x18
00170 #define LCD_MOVE_DISP_RIGHT 0x1C
00171
00172
00173 #define LCD_FUNCTION_4BIT_1LINE 0x20
00174 #define LCD_FUNCTION_4BIT_2LINES 0x28
00175 #define LCD_FUNCTION_8BIT_1LINE 0x30
00176 #define LCD_FUNCTION_8BIT_2LINES 0x38
00177
00178
00179 #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
00180
00181
00182
00196 extern void lcd_init(uint8_t dispAttr);
00197
00198
00204 extern void lcd_clrscr(void);
00205
00206
00212 extern void lcd_home(void);
00213
00214
00222 extern void lcd_gotoxy(uint8_t x, uint8_t y);
00223
00224
00230 extern void lcd_putc(char c);
00231
00232
00238 extern void lcd_puts(const char *s);
00239
00240
00247 extern void lcd_puts_p(const char *progmem_s);
00248
00249
00255 extern void lcd_command(uint8_t cmd);
00256
00257
00265 extern void lcd_data(uint8_t data);
00266
00267
00271 #define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
00272
00274 #endif //LCD_H